(0) Obligation:

The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(1, n^1).


The TRS R consists of the following rules:

f(s(x), x) → f(s(x), round(s(x)))
round(0) → 0
round(0) → s(0)
round(s(0)) → s(0)
round(s(s(x))) → s(s(round(x)))

Rewrite Strategy: INNERMOST

(1) TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID) transformation)

Transformed TRS to weighted TRS

(2) Obligation:

The Runtime Complexity (innermost) of the given CpxWeightedTrs could be proven to be BOUNDS(1, n^1).


The TRS R consists of the following rules:

f(s(x), x) → f(s(x), round(s(x))) [1]
round(0) → 0 [1]
round(0) → s(0) [1]
round(s(0)) → s(0) [1]
round(s(s(x))) → s(s(round(x))) [1]

Rewrite Strategy: INNERMOST

(3) TypeInferenceProof (BOTH BOUNDS(ID, ID) transformation)

Infered types.

(4) Obligation:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

f(s(x), x) → f(s(x), round(s(x))) [1]
round(0) → 0 [1]
round(0) → s(0) [1]
round(s(0)) → s(0) [1]
round(s(s(x))) → s(s(round(x))) [1]

The TRS has the following type information:
f :: s:0 → s:0 → f
s :: s:0 → s:0
round :: s:0 → s:0
0 :: s:0

Rewrite Strategy: INNERMOST

(5) CompletionProof (UPPER BOUND(ID) transformation)

The TRS is a completely defined constructor system, as every type has a constant constructor and the following rules were added:

f(v0, v1) → null_f [0]

And the following fresh constants:

null_f

(6) Obligation:

Runtime Complexity Weighted TRS where all functions are completely defined. The underlying TRS is:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

f(s(x), x) → f(s(x), round(s(x))) [1]
round(0) → 0 [1]
round(0) → s(0) [1]
round(s(0)) → s(0) [1]
round(s(s(x))) → s(s(round(x))) [1]
f(v0, v1) → null_f [0]

The TRS has the following type information:
f :: s:0 → s:0 → null_f
s :: s:0 → s:0
round :: s:0 → s:0
0 :: s:0
null_f :: null_f

Rewrite Strategy: INNERMOST

(7) CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID) transformation)

Transformed the TRS into an over-approximating RNTS by (improved) Size Abstraction.
The constant constructors are abstracted as follows:

0 => 0
null_f => 0

(8) Obligation:

Complexity RNTS consisting of the following rules:

f(z, z') -{ 1 }→ f(1 + x, round(1 + x)) :|: z' = x, x >= 0, z = 1 + x
f(z, z') -{ 0 }→ 0 :|: v0 >= 0, v1 >= 0, z = v0, z' = v1
round(z) -{ 1 }→ 0 :|: z = 0
round(z) -{ 1 }→ 1 + 0 :|: z = 0
round(z) -{ 1 }→ 1 + 0 :|: z = 1 + 0
round(z) -{ 1 }→ 1 + (1 + round(x)) :|: x >= 0, z = 1 + (1 + x)

Only complete derivations are relevant for the runtime complexity.

(9) CompleteCoflocoProof (EQUIVALENT transformation)

Transformed the RNTS (where only complete derivations are relevant) into cost relations for CoFloCo:

eq(start(V, V1),0,[f(V, V1, Out)],[V >= 0,V1 >= 0]).
eq(start(V, V1),0,[round(V, Out)],[V >= 0]).
eq(f(V, V1, Out),1,[round(1 + V2, Ret1),f(1 + V2, Ret1, Ret)],[Out = Ret,V1 = V2,V2 >= 0,V = 1 + V2]).
eq(round(V, Out),1,[],[Out = 0,V = 0]).
eq(round(V, Out),1,[],[Out = 1,V = 0]).
eq(round(V, Out),1,[],[Out = 1,V = 1]).
eq(round(V, Out),1,[round(V3, Ret11)],[Out = 2 + Ret11,V3 >= 0,V = 2 + V3]).
eq(f(V, V1, Out),0,[],[Out = 0,V4 >= 0,V5 >= 0,V = V4,V1 = V5]).
input_output_vars(f(V,V1,Out),[V,V1],[Out]).
input_output_vars(round(V,Out),[V],[Out]).

CoFloCo proof output:
Preprocessing Cost Relations
=====================================

#### Computed strongly connected components
0. recursive : [round/2]
1. recursive : [f/3]
2. non_recursive : [start/2]

#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into round/2
1. SCC is partially evaluated into f/3
2. SCC is partially evaluated into start/2

Control-Flow Refinement of Cost Relations
=====================================

### Specialization of cost equations round/2
* CE 9 is refined into CE [10]
* CE 8 is refined into CE [11]
* CE 7 is refined into CE [12]
* CE 6 is refined into CE [13]


### Cost equations --> "Loop" of round/2
* CEs [11] --> Loop 8
* CEs [12] --> Loop 9
* CEs [13] --> Loop 10
* CEs [10] --> Loop 11

### Ranking functions of CR round(V,Out)
* RF of phase [11]: [V-1]

#### Partial ranking functions of CR round(V,Out)
* Partial RF of phase [11]:
- RF of loop [11:1]:
V-1


### Specialization of cost equations f/3
* CE 5 is refined into CE [14]
* CE 4 is refined into CE [15,16,17]


### Cost equations --> "Loop" of f/3
* CEs [17] --> Loop 12
* CEs [16] --> Loop 13
* CEs [15] --> Loop 14
* CEs [14] --> Loop 15

### Ranking functions of CR f(V,V1,Out)

#### Partial ranking functions of CR f(V,V1,Out)


### Specialization of cost equations start/2
* CE 2 is refined into CE [18,19]
* CE 3 is refined into CE [20,21,22,23,24]


### Cost equations --> "Loop" of start/2
* CEs [23,24] --> Loop 16
* CEs [18,19] --> Loop 17
* CEs [22] --> Loop 18
* CEs [20,21] --> Loop 19

### Ranking functions of CR start(V,V1)

#### Partial ranking functions of CR start(V,V1)


Computing Bounds
=====================================

#### Cost of chains of round(V,Out):
* Chain [[11],10]: 1*it(11)+1
Such that:it(11) =< Out

with precondition: [V=Out,V>=2]

* Chain [[11],9]: 1*it(11)+1
Such that:it(11) =< Out

with precondition: [V+1=Out,V>=2]

* Chain [[11],8]: 1*it(11)+1
Such that:it(11) =< Out

with precondition: [V=Out,V>=3]

* Chain [10]: 1
with precondition: [V=0,Out=0]

* Chain [9]: 1
with precondition: [V=0,Out=1]

* Chain [8]: 1
with precondition: [V=1,Out=1]


#### Cost of chains of f(V,V1,Out):
* Chain [15]: 0
with precondition: [Out=0,V>=0,V1>=0]

* Chain [14,15]: 2
with precondition: [V=1,V1=0,Out=0]

* Chain [13,15]: 1*s(3)+2
Such that:s(3) =< V+1

with precondition: [Out=0,V=V1+1,V>=2]

* Chain [12,15]: 2*s(5)+2
Such that:s(4) =< V
s(5) =< s(4)

with precondition: [Out=0,V1+1=V,V1>=1]


#### Cost of chains of start(V,V1):
* Chain [19]: 1
with precondition: [V=0]

* Chain [18]: 1
with precondition: [V=1]

* Chain [17]: 1*s(10)+2*s(11)+2
Such that:s(9) =< V1+1
s(10) =< V1+2
s(11) =< s(9)

with precondition: [V>=0,V1>=0]

* Chain [16]: 1*s(12)+2*s(14)+1
Such that:s(13) =< V
s(12) =< V+1
s(14) =< s(13)

with precondition: [V>=2]


Closed-form bounds of start(V,V1):
-------------------------------------
* Chain [19] with precondition: [V=0]
- Upper bound: 1
- Complexity: constant
* Chain [18] with precondition: [V=1]
- Upper bound: 1
- Complexity: constant
* Chain [17] with precondition: [V>=0,V1>=0]
- Upper bound: 3*V1+6
- Complexity: n
* Chain [16] with precondition: [V>=2]
- Upper bound: 3*V+2
- Complexity: n

### Maximum cost of start(V,V1): max([3*V+1,nat(V1+1)*2+1+nat(V1+2)])+1
Asymptotic class: n
* Total analysis performed in 108 ms.

(10) BOUNDS(1, n^1)